package org.activequant.core.domainmodel.marketdepth;

import static org.activequant.util.tools.IdentityUtils.equalsTo;
import static org.activequant.util.tools.IdentityUtils.safeCompare;
import static org.activequant.util.tools.IdentityUtils.safeHashCode;

import org.activequant.core.domainmodel.InstrumentSpecification;
import org.activequant.core.domainmodel.data.MarketDataEntity;

public class MarketDepthEvent extends MarketDataEntity<MarketDepthEvent>{
	/**
	 * 
	 */
	private static final long serialVersionUID = 2335626317085038706L;
	/**
	 * final static int OPERATION_INSERT = 0;
	 */
	final static int OPERATION_INSERT = 0;
	/**
	 * final static int OPERATION_UPDATE = 1;
	 */
    final static int OPERATION_UPDATE = 1;
    /**
     * final static int OPERATION_DELETE = 2;
     */
    final static int OPERATION_DELETE = 2;
    /**
     * public final static int SIDE_ASK = 0;
     */
    public final static int SIDE_ASK = 0;
    /**
     * public final static int SIDE_BID = 1;
     */
    public final static int SIDE_BID = 1;
    /**
     * public final static int MKT_DEPTH_DATA_RESET = 317;
     */
    public final static int MKT_DEPTH_DATA_RESET = 317;
	/**
	 * private Long id = null;
	 */
	private Long id = null;
	/**
	 * private Integer position;
	 */
	private Integer position;
	/**
	 * private String marketMaker;
	 */
	private String 	marketMaker;
	/**
	 * private Integer operation;
	 */
	private Integer operation;
	/**
	 * private Integer side;
	 */
	private Integer side;
	/**
	 * private Double price;
	 */
	private Double price;
	/**
	 * private Integer size;
	 */
	private Integer size;
	/**
	 * Returns the associated position(Integer)
	 * @return
	 */
	public Integer getPosition() {
		return position;
	}
	/**
	 * Sets the associated position(Integer) with the given position(Integer)
	 * @param size
	 */
	public void setPosition(Integer position) {
		this.position = position;
	}
	/**
	 * Returns the associated marketMaker(String)
	 * @return
	 */
	public String getMarketMaker() {
		return marketMaker;
	}
	/**
	 * Sets the associated marketMaker(String) with the given marketMaker(String)
	 * @param marketMaker
	 */
	public void setMarketMaker(String marketMaker) {
		this.marketMaker = marketMaker;
	}
	/**
	 * Returns the associated operation(Integer)
	 * @return
	 */
	public Integer getOperation() {
		return operation;
	}
	/**
	 * Sets the associated operation(Integer) with the given operation(Integer)
	 * @param size
	 */
	public void setOperation(Integer operation) {
		this.operation = operation;
	}
	/**
	 * Returns the associated side(Integer)
	 * @return
	 */
	public Integer getSide() {
		return side;
	}
	/**
	 * Sets the associated side(Integer) with the given side(Integer)
	 * @param size
	 */
	public void setSide(Integer side) {
		this.side = side;
	}
	/**
	 * Returns the associated price(Double)
	 * @return
	 */
	public Double getPrice() {
		return price;
	}
	/**
	 * Sets the associated price(Double) with the given price(Double)
	 * @param price
	 */
	public void setPrice(Double price) {
		this.price = price;
	}
	/**
	 * Returns the associated size(Integer)
	 * @return
	 */
	public Integer getSize() {
		return size;
	}
	/**
	 * Sets the associated size(Integer) with the given size(Integer)
	 * @param size
	 */
	public void setSize(Integer size) {
		this.size = size;
	}
	
	public MarketDepthEvent(InstrumentSpecification instrumentSpecification){
		this.setInstrumentSpecification(instrumentSpecification);
	}
	
	public MarketDepthEvent(){
	}
	
	@Override
	public MarketDepthEvent clone() {
		MarketDepthEvent clone=new MarketDepthEvent(this.getInstrumentSpecification());
		clone.setMarketMaker(this.getMarketMaker());
		clone.setOperation(this.getOperation());
		clone.setPosition(this.getPosition());
		clone.setPrice(this.getPrice());
		clone.setSide(this.getSide());
		clone.setSize(this.getSize());
		return clone;
	}

	public int compareTo(MarketDepthEvent other) {
		// ATTENTION: keep in sync with hashCode();
		int rc;
		rc = safeCompare(this.getInstrumentSpecification(), other.getInstrumentSpecification());
		if (rc != 0) return rc;
		rc = safeCompare(this.getTimeStamp(), other.getTimeStamp());
		if (rc != 0) return rc;
		return rc;
	}
	
	/**
	 * {@inheritDoc}
	 */
	@Override
	public int hashCode() {
		// ATTENTION: keep in sync with compareTo();
		return safeHashCode(this.getInstrumentSpecification()) + safeHashCode(this.getTimeStamp());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean equals(Object other) {
		// NOTE: delegates to compareTo()
		return equalsTo(this, other);
	}
	
}
